<?php
	header('Content-type: images/jpeg');
	session_start();
	
	$number = $_SESSION['captcha'];
	$font_size = 25;
	$width = 250;
	$height = 50;
	
	$captcha = imagecreate($width, $height);
	imagecolorallocate($captcha, 255, 255, 255);
	
	$color = imagecolorallocate($captcha, 0, 0, 0);
	
	for ($i = 0; $i < 30; $i++) {
		$x1 = rand(1, 250);
		$y1 = rand(1, 100);
		$x2 = rand(1, 250);
		$y2 = rand(1, 100);

		imageline($captcha, $x1, $y1, $x2, $y2, $color);
	}
	
	imagettftext($captcha, $font_size, 0, 75, 40, $color, './captcha.ttf', $number);
	
	imagejpeg($captcha);
?>
